/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package it.baumi.tankwars.entities;

/**
 *
 * @author Michael Baumgartner
 */
public abstract class MoveableEntity2D extends BlockEntity2D {

    protected double speed;
    protected double lastX;
    protected double lastY;

    public MoveableEntity2D(double x, double y, double width, double height, double speed) {
        super(x, y, width, height);
        this.speed = speed;
        lastY = y;
        lastX = x;
    }

    public double getSpeed() {
        return speed;
    }

    public void setSpeed(double speed) {
        this.speed = speed;
    }

    public void moveNorth(double delta) {
        if (delta != 0) {
            lastX = x;
            lastY = y;
        }
        this.y -= speed * delta;
    }

    public void moveSouth(double delta) {
        if (delta != 0) {
            lastX = x;
            lastY = y;
        }
        this.y += speed * delta;
    }

    public void moveEast(double delta) {
        if (delta != 0) {
            lastX = x;
            lastY = y;
        }
        this.x += speed * delta;
    }

    public void moveWest(double delta) {
        if (delta != 0) {
            lastX = x;
            lastY = y;
        }
        this.x -= speed * delta;

    }

}
